package com.jia.train.seat.controller;

import com.jia.train.global.page.PageResponse;
import com.jia.train.global.response.BaseResponse;
import com.jia.train.seat.request.TripStationQueryRequest;
import com.jia.train.seat.request.TripStationSaveRequest;
import com.jia.train.seat.response.TripStationQueryResponse;
import com.jia.train.seat.response.TripStationSaveResponse;
import com.jia.train.seat.service.TripStationService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/trip/station")
public class TripStationController {

    @Resource
    private TripStationService tripStationService;

    @PostMapping("/insert")
    public BaseResponse<TripStationSaveResponse> insertTripStation(@Valid @RequestBody TripStationSaveRequest request) {
        TripStationSaveResponse response = tripStationService.insert(request);
        return new BaseResponse<>(response);
    }

    @GetMapping("/query")
    public BaseResponse<PageResponse<TripStationQueryResponse>> query(@Valid TripStationQueryRequest request) {
        PageResponse<TripStationQueryResponse> responseList = tripStationService.selectList(request);
        return new BaseResponse<>(responseList);
    }

    @DeleteMapping("/delete/{id}")
    public BaseResponse<String> delete(@PathVariable Long id) {
        tripStationService.deleteTripStation(id);
        return new BaseResponse<>("success");
    }

}
